	<div id="jasperReport<?php echo $reportdef['id']?>"></div>
	<script type="text/javascript">
		function refresh<?php echo $reportdef['id']?>(){
			document.getElementById('jasperReport<?php echo $reportdef['id']?>').innerHTML = "<div \"style: text-align:center;\"><img style=\"width:66px;height:66px;\" alt=\"<?php echo __('wait please...'); ?>\" src=\"/images/ajax-loader-large.gif\"></div>";
			
			var $inputs = $(':input');
			var query = ''; 
			var first = true;
		    for(var i= 0; i < $inputs.length; i++)
		    {
		        if(first){
		            var symbol = '';
		        }else{
		        	var symbol = '&';
		        }
		        first = false;
		        if($inputs[i].name!=''){
		        	switch ($inputs[i].type) {
	        		case "checkbox":
		            var inputValue = $inputs[i].checked;
			        break;
		        		case "select-multiple":
			    		options = new Array();
			    		for(var j= 0; j < $inputs[i].options.length; j++){
							if($inputs[i].options[j].selected){
								options.push($inputs[i].options[j].value);
							}
			    		}
			    		var inputValue = array2json(options);
		        	break;
		        		default: 
					    var inputValue = $inputs[i].value;
				    }
			        
		    		query = query+symbol+$inputs[i].name+'='+inputValue;

		        }
		    };

		    xhr = getXmlHttpRequest2();
			xhr.onreadystatechange = function(){
				if(xhr.readyState == 4 && xhr.status == 200)
					{
					tableData = xhr.responseText;
					document.getElementById('jasperReport<?php echo $reportdef['id']?>').innerHTML = tableData;
				}
			};
			xhr.open("POST","<?php print url_for('reports/getData'); ?>",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xhr.send("id="+<?php echo $reportdef['id']?>+"&"+query);
			
		}

		function exporter<?php echo $reportdef['id']?>(format){
			
			//I send all imputs to send also the search values! 
			var $inputs = $(':input');
			var query = '<?php print url_for('reports/exportData?id='.$reportdef['id']); ?>'; 
			var first = true;
		    for(var i= 0; i < $inputs.length; i++)
		    {
		        if(first){
		            var symbol = '?';
		        }else{
		        	var symbol = '&';
		        }
		        first = false;
		        if($inputs[i].name!=''){
			        if($inputs[i].type == "checkbox"){
				        var inputValue = $inputs[i].checked;
			        }else{
			        	var inputValue = $inputs[i].value;
			        }
		    		query = query+symbol+$inputs[i].name+'='+inputValue;
		        }
		    };
		    query = query+'&format='+format;
			var elemIF = document.createElement("iframe");
			elemIF.src = query; 
			elemIF.id = 'upload_target'; 
			elemIF.style.display = "none"; 
			document.body.appendChild(elemIF);
		
		}		
		
	</script>